package com.dragon.pojo.enums;

import lombok.Getter;

import java.util.Objects;

@Getter

public enum JudgeInfoMessageEnum {
    /**
     * 运行的结果
     */

    ACCEPTED("Accepted",1),
    WRONG_ANSWER("Wrong Answer",2),
    COMPILE_ERROR("Compile Error",3),
    MEMORY_LIMIT_EXCEEDED("Out of Memory",4),
    TIME_LIMIT_EXCEEDED("Time Limit Exceeded",5),
    PRESENTATION_ERROR("Presentation Error",6),
    RUNTIME_ERROR("Runtime Error",7),
    OUTPUT_LIMIT_EXCEEDED("Output Limit Exceeded",8),
    SYSTEM_ERROR("System Error", 9),
    DANGEROUS_OPERATION("Dangerous Operation", 10);


    private final String info;

    private final Integer value;

    JudgeInfoMessageEnum(String info, Integer value) {
        this.info = info;
        this.value = value;
    }

    /**
     * 根据 value 获取枚举
     * @param sta status 状态码
     * @return info
     */
    public static String getInfoByValue(Integer sta) {
        for (JudgeInfoMessageEnum item : JudgeInfoMessageEnum.values()) {
            if(Objects.equals(item.value, sta)){
                return item.info;
            }
        }
        return null;
    }

}
